<?php
 /*
 * 1626cms 登錄頁面
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once('../data/config.php');
require_once('./include/admin_common.inc.php');
$act = !empty($_REQUEST['act']) ? trim($_REQUEST['act']) : 'login';
if($act == 'logout'){
unset($_SESSION['admin_id']);
unset($_SESSION['admin_name']);
unset($_SESSION['admin_purview']);
setcookie('Qishi[admin_id]', '');
setcookie('Qishi[admin_name]', '');
setcookie('Qishi[admin_pwd]', '');
$act = 'login';
}
if($act == 'login'){
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
if($_SESSION['admin_id']){
$links[0]['text'] = '管理中心首頁';
$links[0]['href'] = 'admin_index.php';
showmsg('您已登錄，不用再次登錄',1,$links);
}
$smarty->assign('random',mt_rand());
$smarty->assign("QISHI_VERSION",QISHI_VERSION);
$smarty->display('admin_login.htm');
}
elseif($act == 'do_login'){
 	$admin_name = isset($_POST['admin_name']) ? trim($_POST['admin_name']) : '';
 	$admin_pwd = isset($_POST['admin_pwd']) ? trim($_POST['admin_pwd']) : '';
	$admin_Graphics = isset($_POST['admin_Graphics']) ? trim($_POST['admin_Graphics']) : '';
 	$remember = isset($_POST) ? intval($_POST['rememberme']) : 0;
 	if($admin_name == ''){
 	showmsg('用戶名不能為空！',1);
 	}
 	if($admin_pwd == ''){
 	showmsg('密碼不能為空！',1);
 	}
	if($admin_Graphics == ''){
 	showmsg('驗證碼不能為空！',1);
 	}
	include_once(ADMIN_ROOT_PATH.'include/captcha.php');
	$validator = new captcha();
if (!$validator->check_word($admin_Graphics))
   {
 	showmsg('驗證碼填寫錯誤!',1);
 	}
 	if(check_admin($admin_name, $admin_pwd)){
 		update_admin_info($admin_name);
		write_log("成功登錄",$admin_name);
 		if($remember == 1){
 			setcookie('Qishi[admin_id]', $_SESSION['admin_id'], time()+86400, $cookiepath, $cookiedomain);
 			setcookie('Qishi[admin_name]', $admin_name, time()+86400, $cookiepath, $cookiedomain);
			setcookie('Qishi[admin_pwd]', md5(md5($admin_pwd).$_CFG['cookie_hash']), time()+86400, $cookiepath, $cookiedomain);
 		}
 	}else{
 		showmsg('您輸入的用戶名和密碼有誤！',1);
 	}
header("Location: admin_index.php"); 
}
?>
